package com.woniuxy.microretailserver.controller;

import com.woniuxy.microretailserver.bean.RefundCountDateBean;
import com.woniuxy.microretailserver.service.IRefundCountService;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * @author chenhu
 * 财务退款汇总控制层
 */
@RestController
@RequestMapping("/frs")
public class FinRefSumController {

    @Resource
    private IRefundCountService refundCountServiceImpl;

    /**
     * 展示或查询财务退款汇总信息
     * @param
     * @return
     */
    @RequestMapping(value = "/findTime",produces = MediaType.APPLICATION_JSON_VALUE)
    public List<RefundCountDateBean> findAll(){
        List<RefundCountDateBean> all = refundCountServiceImpl.findAll();
        all.forEach(e->{
            System.out.println(e);
        });
        return all;
    }

    /**
     * 按时间查询退款表中的金额汇总
     * @param time
     * @return
     */
    @GetMapping(value = "/findReBy",produces = MediaType.APPLICATION_JSON_VALUE)
    public List<RefundCountDateBean> findReByTime(String time){
        List<RefundCountDateBean> reByTime = refundCountServiceImpl.findReByTime(time);
        reByTime.forEach(e->{
            System.out.println(e);
        });
        return reByTime;
    }
}
